local PrintProgress = true
local function Print(Text)
    if (PrintProgress) then
        print(Text)
    end
end
 
-- A simple function to makes sure they got the right extension (so it's not .txt for example)
local function ValidExt(FileName)
    if  -- Materials
      --  (FileName:find(".vtf$")) or
      --  (FileName:find(".vmt$")) or
        -- Models
      --  (FileName:find(".vtx$")) or
        (FileName:find(".mdl$")) or
        (FileName:find(".phy$")) or
		(FileName:find(".mp3$")) or
		(FileName:find("note")) -- or
	--	(FileName:find(".wav$")) or
	--	(FileName:find(".wav$")) or
    --   (FileName:find(".vvd$")) 
		then
        
        return true
    end
    
    return false
end
 
-- A recursive function to find all the files in models and material folders (don't use the Level argument)
local function FindFiles(Dir, Level)
    if (Dir) then
        Files = file.Find("../gamemodes/Freelancer/content/"..Dir.."/*.*")
    else
        Files = file.Find("../gamemodes/Freelancer/content/*.*")
        Print("-------------------------------------------------")
        Print("------- ADDING RESOURCES TO DOWNLOAD LIST -------")
        Print("-------------------------------------------------")
    end
    
    Level = Level or 0
    Dir = Dir or ""
    for k,v in pairs(Files) do
        local IsDir = file.IsDir("../gamemodes/Freelancer/content/".. Dir .. "/" .. v)
        if (IsDir) then
            FindFiles(Dir .. "/" .. v, Level + 1)
        else
            if (ValidExt(v)) then
                local unconvert = Dir .. "/" .. v
				resource.AddFile(string.Right(unconvert,string.len(unconvert) -1))
            else
            end
        end
    end
end
 
-- We need to start the function somewhere
-- FindFiles()